
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <BEntry>
#include <BComboBox>
#include <BLineEdit>
#include <BListWidget>
#include <BTreeWidget>
#include <BHtmlWidget>
#include <BMainWindow>
#include <BXmlDocument>

#include "Config.h"

class MainWindow : public BMainWindow
{
	BOBJECT(MainWindow)
public:
	MainWindow(BWidget* parent = 0);
	~MainWindow();

	void openHtmlPage(const BString& fileName);

protected:
	BTreeItem* createTreeItem(BEntry* entry);
	void freshItemIcon(BTreeItem* item);
	void searchTreeItem(BTreeItem* item);
	void searchHtmlItem(BHtmlItem* item);

protected:
	void slotLanguageCurrentChanged(BObject* object, const BValue& value);
	void slotSearchEditFinished(BObject* object, const BValue& value);
	void slotSearchButtonClicked(BObject* object, const BValue& value);
	void slotItemDoubleClicked(BObject* object, const BValue& value);
	void slotHtmlItemSelected(BObject* object, const BValue& value);
	void slotHtmlItemClicked(BHtmlWidget* htmlWidget, const BValue& value);
	void slotHtmlWidgetFramed(BObject* object, const BValue& value);

protected:
	virtual void updateEvent(const BEvent& event) override;
	virtual void styleEvent(const BEvent& event) override;

private:
	BComboBox*		_languageComboBox;
	BComboBox*		_searchComboBox;
	BButton*		_searchButton;
	BTreeWidget*	_htmlTreeWidget;
	BTreeItemHolder	_searchingItem;
	BListWidget*	_searchListWidget;

	BButton*		_prevButton;
	BButton*		_nextButton;
	BButton*		_aboveButton;
	BComboBox*		_pathComboBox;
	BHtmlWidget*	_htmlWidget;

	BHolder<Config>	_config;
	BXmlDocument	_document;
	BHtmlItem*		_strikingItem;
	BReal			_selectTick;
};

#endif
